package com.huihui.activity;

import android.os.Bundle;
import android.widget.ImageView;

import com.huihui.R;
import com.huihui.base.BaseActivity;
import com.huihui.datamanager.AppManager;
import com.huihui.utils.IntentUtils;

public class SplashActivity extends BaseActivity {

    private ImageView spash;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        spash = findViewById(R.id.spash);

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1000);
                    initLogin();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }

    private void initLogin(){
        if(AppManager.getUserInfo() != null){
            setUserInfo(AppManager.getUserInfo());
            IntentUtils.gotoMainActivity(getContext());
            finish();
        }else{
            IntentUtils.gotoLoginActivity(getContext());
            finish();
        }
    }
}
